package com.bibi.hanshunping.chapter07;

public class RecursionExercise01 {
    public static void main(String[] args) {
        Fibonacci fibonacci = new Fibonacci();
        int result = fibonacci.run(7);
        System.out.println(result);

        int res = fibonacci.peach(11);
        System.out.println(res);
    }
}

class Fibonacci {

    public int run(int n) {
        if (n <= 2) {
            return 1;
        } else {
            return run(n - 1) + run(n -2);
        }
    }

    public int peach(int day) {

        // f(n - 1) = (f(n) + 1) * 2;
        // f(10) = 1
        if (day == 10) return 1;
        if (day > 0 && day < 10) {
            return (peach(day + 1) + 1) + 2;
        } else {
            System.out.println("0 < day < 10");
            return -1;
        }

    }
}
